package 高效制胜._06;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/9/13 9:23
 * 杨辉三角 II
 * 算法：动态规划
 */
public class _119 {
    static int[][] list;
    static {
        list = new int[34][35];
        list[0][0] = 1;
        for (int i = 1; i <= 33; i++) {
            for (int j = 0; j <= i + 1; j++) {
                if (j == 0) list[i][j] = list[i - 1][j];
                else list[i][j] = list[i - 1][j - 1] + list[i - 1][j];
            }
        }
    }

    public static void main(String[] args) {
        System.out.println(new _119().getRow(3));
    }

    public List<Integer> getRow(int rowIndex) {
        List<Integer> ans = new ArrayList<>(rowIndex + 1);
        for (int i = 0; i < rowIndex + 1; i++) ans.add(list[rowIndex][i]);
        return ans;
    }
}
